package com.gupao.factory;

import com.gupao.factory.computer.Computer;
import com.gupao.factory.abstr.DefaultFactory;
import com.gupao.factory.func.FuncFactory;
import com.gupao.factory.func.LenovoFactory;
import com.gupao.factory.simple.SimpleFactory;

/**
 * 测试类
 * Created by ktyan on 2017/5/21.
 */
public class FactoryTest
{
    public static void main(String args[])
    {
        // 电脑品牌
        String brandName = "Dell";
        // 简单工厂测试
        Computer simpleComputer = null;
        simpleComputer = new SimpleFactory().getComputer(brandName);
        if (simpleComputer == null)
        {
            System.out.println("SimpleFactory 工厂未找到该品牌电脑");
        }
        else
        {
            System.out.println("我买了一台" + simpleComputer.getBranName()
                    + "笔记本电脑,由SimpleFactor工厂生产！");
        }
        
        // 方法工厂测试
        FuncFactory funcFactory = new LenovoFactory();
        Computer funcComputer = funcFactory.getComputer();
        System.out.println("小明买了一台" + funcComputer.getBranName()
                + "笔记本电脑,由FuncFactor工厂生产！");
        
        // 抽象工厂测试
        brandName = "MacBook";
        DefaultFactory defaultFactory = new DefaultFactory();
        Computer dComputer = defaultFactory.getComputer(brandName);
        System.out.println("小王买了一台" + dComputer.getBranName()
                + "笔记本电脑,由DefaultFactory工厂生产！");
    }
}
